#include<iostream>
#include<pthread.h>
#include<unistd.h>

pthread_cond_t con_=PTHREAD_COND_INITIALIZER;
pthread_mutex_t mutex_=PTHREAD_MUTEX_INITIALIZER;
using namespace std;
void *routineFunc(void*args)
{
  while(1)
  {
    pthread_cond_wait(&con_,&mutex_);
    cout<<pthread_self()<<": is running!"<<endl;
  }
  return nullptr;
}
int main()
{
  pthread_t t1,t2,t3;
  pthread_create(&t1,nullptr,routineFunc,(void*)"thread 1");
  pthread_create(&t2,nullptr,routineFunc,(void*)"thread 2");
  pthread_create(&t3,nullptr,routineFunc,(void*)"thread 3");
  while(1)
  {
    pthread_cond_signal(&con_);
    sleep(1);
  }
  return 0;
}
